package com.liuweiheng.cloud.future;

import java.util.concurrent.Callable;

public class RealData implements Data, Callable<String> {

    protected final String result;

    public RealData(String para) {
        StringBuilder sb = new StringBuilder(para);
        // 假设这里执行很慢，构建需要一段时间
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {

        }
        result = sb.toString();
    }

    @Override
    public String getResult() {
        return result;
    }

    @Override
    public String call() throws Exception {
        System.out.println("进入了：" + Thread.currentThread().getName());
        return getResult();
    }
}
